package leetcodecompetition.D369;

/**
 * @Author: Siantar
 * @Date: 2023-10-29-10:43
 * @Description: 1.0
 */
public class T100102 {
    public long minSum(int[] nums1, int[] nums2) {
        long sum1 = 0, zeroCnt1 = 0, sum2 = 0, zeroCnt2 = 0;
        for (int num : nums1) {
            sum1 += num;
            if (num == 0) zeroCnt1++;
        }
        for (int num : nums2) {
            sum2 += num;
            if (num == 0) zeroCnt2++;
        }
        System.out.println(sum1+" "+sum2+" "+zeroCnt1+" "+zeroCnt2);
        if (zeroCnt1 == 0 && sum1 < sum2 + zeroCnt2 || zeroCnt2 == 0 && sum2 < sum1 + zeroCnt1) return -1;
        return Math.max(zeroCnt2, zeroCnt1 + sum2 - sum1) + sum2;
    }
}
